package servlets;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import bdd.Connexion;
import beans.ListeArticle;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author maboisba
 */
public class ListeArticlesServlet extends HttpServlet {

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String url = request.getRealPath("WEB-INF/prop.properties");
    
    Connexion connexion = new Connexion(url);
    connexion.connexion();
    ListeArticle articles = connexion.getArticles();
    connexion.deconnexion();
    request.setAttribute("articles", articles);
    request.getRequestDispatcher("index.jsp").forward(request, response);

  }

  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
    doGet(request, response);
  }
}
